package com.company;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class UDPClient {

    public static void main(String[] args) throws Exception {
        DatagramSocket client = new DatagramSocket(9999);
        byte[] data = new byte[1024];
        DatagramPacket packet = new DatagramPacket(data, data.length);
        System.out.println("Client is waiting for message ....");
        client.receive(packet);
        System.out.println(
                "The message which client accept is that " +
                new String(data, 0, packet.getLength())
        );
        client.close();
    }
}
